<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>JsRunnerGadget</title>
<meta name="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="./lib/codemirror.js"></script>
<script type="text/javascript" src="./mode/javascript/javascript.js"></script>
<script type="text/javascript" src="./lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="./lib/jquery.console.js"></script>
<script type="text/javascript">
function puts(msg,className) {
	var inner = $('.jquery-console-inner');
	var mesg = $('<div class="jquery-console-message"></div>');
	if(className){
		mesg.addClass(className);
	}
	mesg.filledText(msg).hide();
	inner.append(mesg);
	mesg.show();
};
$(document).ready(function(){
	var editor = CodeMirror.fromTextArea(document.getElementById("editarea"), {
	  	lineNumbers: true,
	  	matchBrackets: true
	});
	var myconsole = $('<div class="console">');
	$('body').append(myconsole);
	var mycontroller = myconsole.console({
		promptLabel: '> ',
		commandValidate:function(line){
			return true;
		},
		commandHandle:function(line){
			try {
				var ret = eval(line);
				if (typeof ret != 'undefined') return ret.toString();
				else return true;
			} catch (e) {
				return e.toString();
			}
		},
		animateScroll:true,
		promptHistory:true,
		welcomeMessage:'Enter some JavaScript expressions to evaluate.',
		command:editor,
		runButton:$('#run')
	});
});
</script>
<link rel="stylesheet" href="./lib/codemirror.css">
<link rel="stylesheet" href="./theme/default.css">
<style type="text/css">
body {
	margin:1em; }
.CodeMirror {
	border-top: 1px solid silver; border-bottom: 1px solid silver; border-right: 1px solid silver; }
div.console {
	font-size: 14px; margin-top:1em }
div.console div.jquery-console-inner {
	height:14em; background:#efefef; padding:0.5em; overflow:auto }
div.console div.jquery-console-prompt-box {
	color:#444; font-family:monospace; }
div.console div.jquery-console-focus span.jquery-console-cursor {
	background:#333; color:#eee; font-weight:bold }
div.console div.jquery-console-message-error {
	color:#ef0505; font-family:sans-serif; font-weight:bold; padding:0.1em; }
div.console div.jquery-console-message-success {
	color:#187718; font-family:monospace; padding:0.1em; }
div.console span.jquery-console-prompt-label {
	font-weight:bold }
</style>
<noscript>
<p>
<strong>Please enable JavaScript or upgrade your browser.</strong>
</p>
</noscript>
</head>
<body>
<input type="button" id="run" value="Run (F5)"/>
<textarea id="editarea"></textarea>
</body>
</html>
